import { ApiProperty } from '@nestjs/swagger';
import { IsInt, IsString } from 'class-validator';
import {
  Column,
  CreateDateColumn,
  Entity,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
@Entity()
export class Gather {
  @ApiProperty({ description: 'id' })
  @IsInt()
  @PrimaryGeneratedColumn()
  id: number;

  @ApiProperty()
  @IsString()
  @Column()
  name: string;

  @ApiProperty({ description: '封面' })
  @IsString()
  @Column()
  cover: string;

  @ApiProperty({ description: '分类id' })
  @IsInt()
  @Column()
  classificationId: number;

  @ApiProperty({ description: '分类名称' })
  @IsString()
  @Column()
  classificationName: string;

  @ApiProperty({ description: '作者' })
  @IsString()
  @Column()
  author: string;

  @ApiProperty({ description: '介绍' })
  @IsString()
  @Column()
  intro: string;

  @ApiProperty({ description: '文章数量' })
  @IsInt()
  @Column()
  articleTotal: number;

  @ApiProperty({ description: '是否已收藏, 0:未收藏 1:已收藏' })
  @IsString()
  isCollected: string;

  @ApiProperty({ description: '阅读进度' })
  @IsString()
  progress: string;

  // @ApiProperty()
  // @OneToMany(() => Article, (article: Article) => article.gatherId)
  // articles: Article[];

  // @ApiProperty({ description: '文章数量' })
  // @OneToMany(() => Article, (article: Article) => article.gatherId)
  // articleTotal: number;

  @ApiProperty()
  @CreateDateColumn({ type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
  createdAt: string;

  @ApiProperty()
  @UpdateDateColumn({
    type: 'timestamptz',
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
  })
  updatedAt: string;
}
